﻿
using Ops.Mpc.ExampleApplication.ExampleService;
using Ops.Mpc.Models;
using Ops.Mpc.ValidationServices.Attributes;
using System.ComponentModel.DataAnnotations;

namespace Ops.Mpc.ExampleApplication.SimpleBindings.Models
{
    public class SimpleModel : Model<SimpleModel>
    {
        #region Fields & Properties
        private string _firstName = string.Empty;
        private string _lastName = string.Empty;
        private int? _personId = null;

        public int? PersonId
        {
            get
            {
                return this._personId;
            }

            set
            {
                this._personId = value;
                this.RaisePropertyChanged(model => model.PersonId);
            }

        }

        [RequiredString(MinimumLength=1,Message="Please enter a {0}")]
        [Display(Name="First Name")]
        public string FirstName
        {
            get
            {
                return this._firstName;
            }

            set
            {
                this._firstName = value;
                this.RaisePropertyChanged(model => model.FirstName);
            }
        }

        [RequiredString(MinimumLength = 1, Message = "Please enter a {0}")]
        [Display(Name = "Last Name")]
        public string LastName
        {
            get
            {
                return this._lastName;
            }

            set
            {
                this._lastName = value;
                this.RaisePropertyChanged(model => model.LastName);
            }
        }

        #endregion

        #region Methods
        public void Set(Person person)
        {
            this.FirstName = person.FirstName;
            this.LastName = person.LastName;
            this.PersonId = person.PersonId;
        }

        #endregion
    }
}
